#include<iostream>
using namespace std;
int max_one(int* s1, int n)
{
	int max = 0;
	int b = 0;
	for (int i = 0; i < n; i++)
	{
		if (b > 0)	b += s1[i];
		else
		{
			b = s1[i];
		}
		if (b > max)	max = b;
	}
	return max;
}
int max_second(int** s2, int n)
{
	int max = 0;
	int* b = new int[n];
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			b[j] = 0;
		}
		for (int j = i; j < n; j++)
		{
			for (int t = 0; t < n; t++)
			{
				b[t] += s2[j][t];
			}
			int temp = max_one(b, n);
			if (temp > max)	max = temp;
		}
		
	}
	return max;
}
int main()
{
	int n,b(0),max(0);
	cin >> n;
	int** default_s = new int* [n];
	for (int i = 0; i < n; i++)
	{
		default_s[i] = new int[n];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> default_s[i][j];
		}
	}
	max = max_second(default_s, n);
	cout << max<<endl;
	return 0;
}